# encoding = utf-8
class UpdateController < ApplicationController
  
  before_filter :authenticate_admin!

  def update_user_address
    users = User.all
    users.each do |user|
      if !user.info.nil?
        info = user.info
        info.building_id = info.company.building.id
        info.company_name = info.company.name
        info.floor = info.company.floor
        info.save
      end
    end
    render :text => 'success'
  end

  def update_user_tower
    users = User.all
    users.each do |user|
      if !user.info.nil?
        info = user.info
        if info.building_id == 1
          info.tower = 'A座'
        elsif info.building_id == 2
          info.tower = 'F座'
        elsif info.building_id == 3
          info.tower = '3号'
        end

        info.save
      end
    end
    render :text => 'success'
  end
end
